package com.efuture.reflect;

/**
 * @ClassNAME NewInstance
 * @Description 通过反射获取实例化对象
 * @Author zhaoshanshan
 * @Date 2021/9/11 4:10 下午
 * @Version 1.0
 */
public class NewInstance {

    public static void main(String[] args) {
        try{
            Class c=  Class.forName("com.efuture.reflect.User");
            User user = (User)c.newInstance(); //这句代码会创建一个对象
        }catch (Exception e){

        }
    }
}
class User{
    public User(){
        System.out.println("我是无参构造");
    }

}